package com.battle.service.controller.web;

import com.battle.pojo.param.studyUser.*;
import com.battle.pojo.vo.studyUser.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
*   web/用户学习计划
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@RestController
@RequestMapping("/studyUser/web")
public class StudyUserWebController {

private final StudyUserService service;

public StudyUserWebController(StudyUserService service) {
this.service = service;
}


/**
* 创建用户学习计划
* @param param
* @return
*/
@PostMapping("/createStudyUser")
public ApiResult createStudyUser(@RequestBody @Valid CreateStudyUserParam param){
service.createStudyUser(param);
return ApiResult.ok();
}


/**
* 修改用户学习计划
* @param param
*/
@PutMapping("/editStudyUser")
public ApiResult editStudyUser(@RequestBody @Valid EditStudyUserParam param){
service.editStudyUser(param);
return ApiResult.ok();
}

/**
* 移除用户学习计划
* @param id
*/
@DeleteMapping("/removeStudyUser")
public ApiResult removeStudyUser(@RequestParam("id") Long id){
service.removeStudyUser(id);
return ApiResult.ok();
}

/**
* 启动/禁用用户学习计划
* @param id
*/
@GetMapping("/enabledStudyUser")
public ApiResult enabledStudyUser(@RequestParam("id") Long id){
service.enabledStudyUser(id);
return ApiResult.ok();
}

/**
* 获取用户学习计划详情
* @param id
* @return
*/
@GetMapping("/getStudyUser")
public ApiResult< GetStudyUserVo> getStudyUser(@RequestParam("id") Long id){
GetStudyUserVo vo = service.getStudyUser(id);
return ApiResult.ok(vo);
}

/**
* 获取用户学习计划列表
* @param param
* @return
*/
@PostMapping("/getStudyUserList")
public ApiResult< PageResult< GetStudyUserListVo>> getStudyUserList(@RequestBody GetStudyUserListParam param){
PageResult< GetStudyUserListVo> result = service.getStudyUserList(param);
return ApiResult.ok(result);
}


/**
* 获取用户学习计划下拉列表
*
* @return
*/
@PostMapping("/getStudyUserDownList")
public ApiResult< List< GetStudyUserDownListVo > > getStudyUserDownList(@RequestBody(required = false) @Valid GetStudyUserDownListParam param) {
List< GetStudyUserDownListVo > list = service.getStudyUserDownList(param);
return ApiResult.ok(list);
}


}

